package y_2025.m03.d21.饿汉模式;

public class Main {
    public static void main(String[] args) {
        GirlFriend instance = GirlFriend.getInstance();
        System.out.println("instance = " + instance);
        GirlFriend instance2 = GirlFriend.getInstance();
        System.out.println("instance2 = " + instance2);
    }
}
class GirlFriend {
    private String name;
    private static GirlFriend girlFriend = new GirlFriend("小红");

    private GirlFriend(String name) {
        this.name = name;
    }

    public static GirlFriend getInstance() {
        return girlFriend;
    }

    @Override
    public String toString() {
        return "GirlFriend{" +
                "name='" + name + '\'' +
                '}';
    }
}
